package com.atguigu.tingshu.album.clien;

import com.atguigu.tingshu.album.service.AlbumAttributeValueService;
import com.atguigu.tingshu.album.service.AlbumInfoService;
import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.cache.GuiguCache;
import com.atguigu.tingshu.common.login.GuiLogin;
import com.atguigu.tingshu.model.album.AlbumAttributeValue;
import com.atguigu.tingshu.model.album.AlbumInfo;
import com.atguigu.tingshu.model.album.BaseCategory3;
import com.atguigu.tingshu.model.album.BaseCategoryView;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/***
 * e专辑微服务提供的内容调用控制层
 * 提供给Feign使用，内部调用
 */
@RestController
@RequestMapping(value = "/client/album/albumInfo")
public class AlbumClientController {

    @Autowired
    private AlbumInfoService albumInfoService;

    @Autowired
    private BaseCategoryService baseCategoryService;

    @Autowired
    private AlbumAttributeValueService albumAttributeValueService;

    /**
     * 查询专辑标签数据
     * @param albumId
     * @return
     */
    @GuiguCache(prefix = "getAlbumInfoAttributeList")
    @GetMapping("/getAlbumInfoAttributeList/{albumId}")
    public List<AlbumAttributeValue> getAlbumInfoAttributeList(@PathVariable(value = "albumId") Long albumId){
        return albumInfoService.getAlbumInfoAttributeList(albumId);
    }


    /**
     * 获取专辑数据
     * @param albumId
     * @return
     */
    @GuiguCache(prefix = "/getAlbumInfo")
    @GetMapping(value = "/getAlbumInfo/{albumId}")
    public AlbumInfo getAlbumInfo(@PathVariable(value = "albumId") Long albumId){
        return albumInfoService.getById(albumId);
    }

    /**
     * 获取三级分类
     * @param category3Id
     * @return
     */
    @GuiguCache(prefix = "getBaseCategoryView")
    @GetMapping(value = "/getBaseCategoryView/{category3Id}")
    public BaseCategoryView getBaseCategoryView(@PathVariable(value = "category3Id") Long category3Id){
        return baseCategoryService.getById(category3Id);
    }
    /**
     * 获取三级分类前七名
     * @param category1Id
     * @return
     */
//    @GuiguCache(prefix = "findTopCategory3")
    @GetMapping(value = "/findTopCategory3/{category1Id}")
    public List findTopCategory3(@PathVariable(value = "category1Id") Long category1Id){
        return baseCategoryService.findTopBaseCategory3(category1Id);
    }

    /**
     * 获取专辑统计信息
     * @param albumId
     * @return
     */
    @GuiguCache(prefix = "getAlbumInfoStat")
    @GetMapping("/getAlbumStatMap{albumId}")
    public Map<String,Object> getAlbumInfoStat(@PathVariable(value = "albumId") Long albumId){
        return albumInfoService.getAlbumStatMap(albumId);
    }


    @GuiLogin
    @GetMapping("/isCanComment")
    Boolean isCanComment(@RequestParam Map<String,Long>param){
        return albumInfoService.isCanComment(param);
    }

}
